import type {
  ApplianceDetail,
  ApplianceProgram,
  ApplianceSetting,
  ApplianceCommand,
  HistoryProgram,
} from '@/api/appliance'
import { DemoFridgeFreezer } from '../list'
import netconfig from '@/config/netconfig'
import type { DemoDatasource, DemoAvailableParameter, DemoDetailSettings, MenuDetail } from '@/demo/types'

/**
 * 详情
 */
export const DemoDetail: ApplianceDetail = {
  ...DemoFridgeFreezer,
  enumber: 'KF72FPA56C/01',
  fd: '8888',
  zn: '88888',
  serialnumber: '873020390341001335',
  usageReport: true,
  installable: false,
  guest: false,
  photo: `${netconfig.PHOTO_IMAGE}WN54C8A10W/WN54C8A10W.png`,
  programKey: '',
  programName: null,
  option: null,
  zh: '冰箱',
}

/**
 * 配置
 */
export const DemoSettings: Array<ApplianceSetting> = [
  {
    key: 'BSH.Common.Setting.AllowBackendConnection',
    value: false,
    name: '连接至服务器',
    mediumDescription: '确定是否允许家电与晶御智能服务器建立连接。',
  },
  {
    key: 'BSH.Common.Setting.PowerState',
    value: 'BSH.Common.EnumType.PowerState.On',
    name: '电源状态',
    displayvalue: '开启',
    mediumDescription: '显示家电的电源状态。',
  },
  {
    key: 'Refrigeration.Common.Setting.Freezer.SetpointTemperature',
    value: 5,
    unit: '°C',
    name: '冷冻室温度',
    mediumDescription: '设定冷冻室的温度',
  },
  {
    key: 'Refrigeration.Common.Setting.Refrigerator.SetpointTemperature',
    value: 4,
    unit: '°C',
    name: '冷藏室温度',
    mediumDescription: '设定冷藏室的温度。',
  },
  {
    key: 'Refrigeration.Common.Setting.Refrigerator.SuperMode',
    value: false,
    name: '速冷',
    mediumDescription:
      '可快速冷却较多的食品或加速冰镇饮料，速冷启动后，冷藏室将在较低的温度设定下自动运行一段时间然后自动退出并恢复之前设定的温度。',
  },
  {
    key: 'Refrigeration.Common.Setting.EcoMode',
    value: false,
    name: '节能模式',
    mediumDescription: '冰箱仅满足基本的制冷功能且设定温度稍高，以便节约能源。',
  },
  {
    key: 'Refrigeration.Common.Setting.VacationMode',
    value: false,
    name: '假日模式',
    mediumDescription:
      '如较长一段时间不使用冰箱，可开启假日模式以便节约能源。启动假日模式后，冷藏室设定为+14°C且不可储存任何食品。冷冻室仍保持原来的温度设定。',
  },
  {
    key: 'Refrigeration.Common.Setting.Freezer.SuperMode',
    value: false,
    name: '速冻',
    mediumDescription:
      '食品快速冷冻储存有利于保持鲜味和相关的营养成分，建议在速冻食品前应提前打开速冻功能几个小时，让冷冻室降至较低温度，再放入食品',
  },
  {
    key: 'Refrigeration.Common.Setting.FreshMode',
    value: false,
    name: '保鲜模式',
    mediumDescription:
      '保鲜模式可适当延长食品的保鲜时间，保鲜模式开启后冷藏室自动调节到对应的温度，冷冻室温度保持不变。',
  },
  {
    key: 'Refrigeration.Common.Setting.SmartHygiene.Enabled',
    value: false,
    name: '智感恒鲜杀菌系统',
    mediumDescription:
      '智感恒鲜杀菌系统使用VOC传感器监测冰箱空气质量。如果空气质量变差，将智能启动净化程序。你也会收到空气质量的通知。\n',
  },
  {
    key: 'Refrigeration.Common.Setting.FlexCompartment.SetpointTemperature',
    value: 0,
    unit: '°C',
    name: '温度',
    mediumDescription: '设定多功能室温度。',
  },
  {
    key: 'Refrigeration.Common.Setting.FlexCompartment.Preset',
    value: 'Refrigeration.Common.EnumType.FoodPresets.Undefined',
    name: '预定义',
    mediumDescription: '请选择合适的储存模式。',
  },
  {
    key: 'Refrigeration.Common.Setting.ChillerCommon.SetpointTemperature',
    value: 0,
    unit: '°C',
    name: '温度',
    mediumDescription: '调节保鲜室的温度。',
  },
  {
    key: 'BSH.Common.Setting.ChildLock',
    value: false,
    name: '儿童锁',
    mediumDescription: '激活或停用儿童锁。',
  },
  // {
  //   key: 'Refrigeration.Common.Setting.ChildLockImpact',
  //   value: 'Refrigeration.Common.EnumType.ChildLockImpact.Display',
  //   name: '童锁',
  //   displayvalue: '显示',
  //   mediumDescription: '开启后童锁功能将会启动。',
  // },
  {
    key: 'Refrigeration.Common.Setting.ProximitySensor.Enable',
    value: false,
    name: '智感氛围灯',
    mediumDescription: '开/关',
  },
]
export const DemoSettingsAvailable: DemoDetailSettings = {
  'BSH.Common.Setting.AllowBackendConnection': {
    name: '连接至服务器',
    key: 'BSH.Common.Setting.AllowBackendConnection',
    constraints: {
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription: '确定是否允许家电与晶御智能服务器建立连接。',
  },
  'BSH.Common.Setting.PowerState': {
    name: '电源状态',
    key: 'BSH.Common.Setting.PowerState',
    constraints: {
      allowedvalues: [
        'BSH.Common.EnumType.PowerState.MainsOff',
        'BSH.Common.EnumType.PowerState.Off',
        'BSH.Common.EnumType.PowerState.On',
        'BSH.Common.EnumType.PowerState.Standby',
      ],
      displayvalues: ['关闭', '关闭', '开启', '待机'],
      default: 'BSH.Common.EnumType.PowerState.On',
      access: 'read',
    },
    type: 'BSH.Common.EnumType.PowerState',
    displayvalue: '开启',
    value: 'BSH.Common.EnumType.PowerState.On',
    mediumDescription: '显示家电的电源状态。',
  },
  'Refrigeration.Common.Setting.Freezer.SetpointTemperature': {
    name: '冷冻室温度',
    key: 'Refrigeration.Common.Setting.Freezer.SetpointTemperature',
    constraints: {
      min: -24,
      max: -16,
      stepsize: 1,
      access: 'readWrite',
    },
    unit: '°C',
    type: 'Double',
    value: -24,
    mediumDescription: '设定冷冻室的温度',
  },
  'Refrigeration.Common.Setting.Refrigerator.SetpointTemperature': {
    name: '冷藏室温度',
    key: 'Refrigeration.Common.Setting.Refrigerator.SetpointTemperature',
    constraints: {
      min: 2,
      max: 6,
      stepsize: 1,
      access: 'readWrite',
    },
    unit: '°C',
    type: 'Double',
    value: 2,
    mediumDescription: '设定冷藏室的温度。',
  },
  'Refrigeration.Common.Setting.Refrigerator.SuperMode': {
    name: '速冷',
    key: 'Refrigeration.Common.Setting.Refrigerator.SuperMode',
    constraints: {
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription:
      '可快速冷却较多的食品或加速冰镇饮料，速冷启动后，冷藏室将在较低的温度设定下自动运行一段时间然后自动退出并恢复之前设定的温度。',
  },
  'Refrigeration.Common.Setting.EcoMode': {
    name: '节能模式',
    key: 'Refrigeration.Common.Setting.EcoMode',
    constraints: {
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription: '冰箱仅满足基本的制冷功能且设定温度稍高，以便节约能源。',
  },
  'Refrigeration.Common.Setting.VacationMode': {
    name: '假日模式',
    key: 'Refrigeration.Common.Setting.VacationMode',
    constraints: {
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription:
      '如较长一段时间不使用冰箱，可开启假日模式以便节约能源。启动假日模式后，冷藏室设定为+14°C且不可储存任何食品。冷冻室仍保持原来的温度设定。',
  },
  'Refrigeration.Common.Setting.Freezer.SuperMode': {
    name: '速冻',
    key: 'Refrigeration.Common.Setting.Freezer.SuperMode',
    constraints: {
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription:
      '食品快速冷冻储存有利于保持鲜味和相关的营养成分，建议在速冻食品前应提前打开速冻功能几个小时，让冷冻室降至较低温度，再放入食品',
  },
  'Refrigeration.Common.Setting.FreshMode': {
    name: '保鲜模式',
    key: 'Refrigeration.Common.Setting.FreshMode',
    constraints: {
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription:
      '保鲜模式可适当延长食品的保鲜时间，保鲜模式开启后冷藏室自动调节到对应的温度，冷冻室温度保持不变。',
  },
  'Refrigeration.Common.Setting.SmartHygiene.Enabled': {
    name: '智感恒鲜杀菌系统',
    key: 'Refrigeration.Common.Setting.SmartHygiene.Enabled',
    constraints: {
      default: false,
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription:
      '智感恒鲜杀菌系统使用VOC传感器监测冰箱空气质量。如果空气质量变差，将智能启动净化程序。你也会收到空气质量的通知。\n',
  },
  'Refrigeration.Common.Setting.FlexCompartment.SetpointTemperature': {
    name: '温度',
    key: 'Refrigeration.Common.Setting.FlexCompartment.SetpointTemperature',
    constraints: {
      min: -20,
      max: 12,
      default: 0,
      access: 'readWrite',
    },
    unit: '°C',
    type: 'Double',
    value: 0,
    mediumDescription: '设定多功能室温度。',
  },
  'Refrigeration.Common.Setting.FlexCompartment.Preset': {
    name: '预定义',
    key: 'Refrigeration.Common.Setting.FlexCompartment.Preset',
    constraints: {
      allowedvalues: [
        'Refrigeration.Common.EnumType.FoodPresets.LittleFreezing',
        'Refrigeration.Common.EnumType.FoodPresets.Cool',
        'Refrigeration.Common.EnumType.FoodPresets.Fresh',
        'Refrigeration.Common.EnumType.FoodPresets.DeepFreeze',
        'Refrigeration.Common.EnumType.FoodPresets.Wine',
        'Refrigeration.Common.EnumType.FoodPresets.Custom',
      ],
      displayvalues: ['微冻', '冷藏', '生鲜', '深冻', '酒饮', '自定义类型'],
      access: 'readWrite',
    },
    type: 'Refrigeration.Common.EnumType.FoodPresets',
    value: 'Refrigeration.Common.EnumType.FoodPresets.Undefined',
    mediumDescription: '请选择合适的储存模式。',
  },
  'Refrigeration.Common.Setting.ChillerCommon.SetpointTemperature': {
    name: '温度',
    key: 'Refrigeration.Common.Setting.ChillerCommon.SetpointTemperature',
    constraints: {
      min: -3,
      max: 8,
      stepsize: 1,
      access: 'readWrite',
    },
    unit: '°C',
    type: 'Double',
    value: 1,
    mediumDescription: '调节保鲜室的温度。',
  },
  'BSH.Common.Setting.ChildLock': {
    name: '儿童锁',
    key: 'BSH.Common.Setting.ChildLock',
    constraints: {
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription: '激活或停用儿童锁。',
  },
  'Refrigeration.Common.Setting.ProximitySensor.Enable': {
    name: '智感氛围灯',
    key: 'Refrigeration.Common.Setting.ProximitySensor.Enable',
    constraints: {
      default: false,
      access: 'readWrite',
    },
    type: 'Boolean',
    value: false,
    mediumDescription: '开/关',
  },
}
export const DemoSupportedCommands: Array<ApplianceCommand> = [
  {
    key: 'BSH.Common.Command.DeactivateWiFi',
    name: '关闭无线网络',
  },
  {
    key: 'BSH.Common.Command.AcknowledgeEvent',
    name: ' 确定',
  },
  {
    key: 'BSH.Common.Command.RejectEvent',
    name: '中止',
  },
  {
    key: 'BSH.Common.Command.ApplyNetworkReset',
    name: '重置网络设置',
  },
  {
    key: 'BSH.Common.Command.DisallowCustomerServiceConnection',
    name: '禁止客户服务连接',
  },
  {
    key: 'BSH.Common.Command.AllowCustomerServiceConnectionLocalWiFi',
    name: '允许在本地无线网络中实施客户服务连接',
  },
  {
    key: 'BSH.Common.Command.AllowSoftwareDownload',
    name: '允许下载软件',
  },
  {
    key: 'BSH.Common.Command.ApplyFactoryReset',
    name: '重置为出厂设置',
  },
]

type MenuSetting = {
  key: string
  settingValue: ApplianceSetting[]
}
export const MenuDSettingDetails: MenuSetting[] = [
  {
    key: 'Refrigeration.Common.Setting.Freezer.SetpointTemperature',
    settingValue: [
      {
        constraints: {
          access: 'readWrite',
        },
        key: 'Refrigeration.Common.Setting.Freezer.SuperMode',
        mediumDescription:
          '可快速冷却较多的食品或加速冰镇饮料，速冷启动后，冷藏室将在较低的温度设定下自动运行一段时间然后自动退出并恢复之前设定的温度。',
        name: '速冻',
        type: 'Radio',
        value: false,
      },
      {
        constraints: {
          access: 'readWrite',
          max: 8,
          min: -29,
          stepsize: 1,
        },
        key: 'Refrigeration.Common.Setting.Refrigerator.SetpointTemperature',
        mediumDescription: '设定冷冻室的温度',
        name: '冷冻室温度',
        type: 'Picker',
        scope: [-24, -23, -22, -21, -20, -19, -18, -17],
        unit: '°C',
        value: 5,
      },
    ],
  },
  {
    key: 'Refrigeration.Common.Setting.Refrigerator.SetpointTemperature',
    settingValue: [
      {
        constraints: {
          access: 'readWrite',
        },
        key: 'Refrigeration.Common.Setting.Freezer.SuperMode',
        mediumDescription:
          '可快速冷却较多的食品或加速冰镇饮料，速冷启动后，冷藏室将在较低的温度设定下自动运行一段时间然后自动退出并恢复之前设定的温度。',
        name: '速冷',
        type: 'Radio',
        value: false,
      },
      {
        constraints: {
          access: 'readWrite',
          max: 8,
          min: 3,
          stepsize: 1,
        },
        key: 'Refrigeration.Common.Setting.Refrigerator.SetpointTemperature',
        mediumDescription: '设定冷冻室的温度',
        name: '冷藏室温度',
        type: 'Picker',
        scope: [-24, -23, -22, -21, -20, -19, -18, -17],
        unit: '°C',
        value: 4,
      },
    ],
  },
  {
    key: 'Refrigeration.Common.Setting.SmartHygiene.Enabled',
    settingValue: [
      {
        constraints: { default: false, access: 'readWrite' },
        access: 'readWrite',
        default: false,
        key: 'Refrigeration.Common.Setting.SmartHygiene.Enabled',
        mediumDescription:
          '恒鲜杀菌系统在开启后会自动运行，冰箱内部的空气会被持续净化，冰箱会一直处于恒鲜杀菌系统的保护中。',
        name: '恒鲜杀菌系统',
        type: 'Radio',
        value: true,
      },
    ],
  },
  {
    key: 'Refrigeration.Common.Setting.FlexCompartment.SetpointTemperature',
    settingValue: [
      {
        constraints: { min: -20, max: 6, stepsize: 1, default: 0, access: 'readWrite' },
        access: 'readWrite',
        default: 0,
        max: 6,
        min: -20,
        stepsize: 1,
        key: 'Refrigeration.Common.Setting.FlexCompartment.SetpointTemperature',
        mediumDescription: '设定多功能室温度。',
        name: '温度',
        type: 'Double',
        unit: '°C',
        value: -1,
      },
      {
        constraints: {
          access: 'readWrite',
          allowedvalues: [
            'Refrigeration.Common.EnumType.FoodPresets.LittleFreezing',
            'Refrigeration.Common.EnumType.FoodPresets.Cool',
            'Refrigeration.Common.EnumType.FoodPresets.Fresh',
            'Refrigeration.Common.EnumType.FoodPresets.DeepFreeze',
            'Refrigeration.Common.EnumType.FoodPresets.Custom',
          ],
          displayvalues: ['微冻', '冷藏', '生鲜', '深冻', '自定义类型'],
        },
        displayvalue: '自定义类型',
        key: 'Refrigeration.Common.Setting.FlexCompartment.Preset',
        mediumDescription: '请选择合适的储存模式。',
        name: '预定义',
        type: 'Refrigeration.Common.EnumType.FoodPresets',
        value: 'Refrigeration.Common.EnumType.FoodPresets.Custom',
      },
    ],
  },
  {
    key: 'Refrigeration.Common.Setting.ChillerCommon.SetpointTemperature',
    settingValue: [
      {
        constraints: {
          access: 'readWrite',
          max: 0,
          min: 0,
        },
        key: 'Refrigeration.Common.Setting.ChillerCommon.SetpointTemperature',
        mediumDescription: '调节保鲜室的温度。',
        name: '温度',
        type: 'Double',
        unit: '°C',
        value: 0,
      },
    ],
  },
  {
    key: 'ModeChoose',
    settingValue: [
      {
        constraints: { access: 'readWrite' },
        access: 'readWrite',
        key: 'Refrigeration.Common.Setting.VacationMode',
        mediumDescription:
          '如较长一段时间不使用冰箱，可开启假日模式以便节约能源。启动假日模式后，冷藏室设定为+14°C且不可储存任何食品。冷冻室仍保持原来的温度设定。',
        name: '关闭',
        type: 'Boolean',
        value: false,
      },
      {
        constraints: { access: 'readWrite' },
        access: 'readWrite',
        key: 'Refrigeration.Common.Setting.VacationMode',
        mediumDescription:
          '如较长一段时间不使用冰箱，可开启假日模式以便节约能源。启动假日模式后，冷藏室设定为+14°C且不可储存任何食品。冷冻室仍保持原来的温度设定。',
        name: '假日模式',
        type: 'Boolean',
        value: false,
      },
    ],
  },
]

export default <DemoDatasource>{
  detail: DemoDetail,
  settings: DemoSettings,
  detailSettings: DemoSettingsAvailable,
  commands: DemoSupportedCommands,
  menuSettings: MenuDSettingDetails,
}
